//
//  NewsTableViewCell.m
//  NewProject
//
//  Created by admin on 2017/6/15.
//  Copyright © 2017年 李航飞. All rights reserved.
//

#import "NewsTableViewCell.h"
@interface NewsTableViewCell()
@property(nonatomic,strong)UILabel *titleLabel;
@property(nonatomic,strong)UILabel *timeLabel;
@property(nonatomic,strong)UIView *lineView;
@end

@implementation NewsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textColor = RGB0X(0x333333);
        _titleLabel.font = FONT(14);
        _titleLabel.numberOfLines = 1;
        [self.contentView addSubview:_titleLabel];
        
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.textColor = RGB0X(0x333333);
        _timeLabel.font = FONT(10);
        [self.contentView addSubview:_timeLabel];

        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = RGB0X(0xEDEDED);
        [self.contentView addSubview:_lineView];
        
        [self createConstraint];
    }
    return self;
}

- (void)createConstraint{
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(15/WIDTH_6_SCALE);
        make.top.equalTo(self.contentView.mas_top).offset(23/WIDTH_6_SCALE);
        make.right.equalTo(self.contentView.mas_right).offset(-15/WIDTH_6_SCALE);
    }];
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-15/WIDTH_6_SCALE);
        make.top.equalTo(self.titleLabel.mas_bottom).offset(11/WIDTH_6_SCALE);
    }];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(14/WIDTH_6_SCALE);
        make.right.equalTo(self.contentView.mas_right).offset(-14/WIDTH_6_SCALE);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-1/WIDTH_6_SCALE);
        make.height.mas_equalTo(1/WIDTH_6_SCALE);
    }];
}

- (void)setModel:(NSDictionary *)model{
    _titleLabel.text = model[kTitle];
    if ([model[kType]isEqualToString:@"0"]) {
        _titleLabel.textColor = RGB0X(0x333333);
    }else{
        _titleLabel.textColor = RGB0X(0x999999);
    }
    _timeLabel.text = model[kTime];
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
